var data;
$(document).ready(function(){
	getIndustry();
    $('#begintime').date();
    $('#endtime').date();
    $(":radio").click(function () {
        var r = $(this).attr("name");
        $(":radio[name=" + r + "]:not(:checked)").attr("tag", 0);
        if ($(this).attr("tag") == 1) {
            $(this).attr("checked", false);
            $(this).attr("tag", 0);
        }
        else {
            $(this).attr("tag",1);
        }
    });
    $("#uploadImage").on("change",function(){
        var files= !!this.files?this.files:[];
        if(!files.length||!window.FileReader)
        	return;
        if(/^image/.test(files[0].type)){
            var reader = new FileReader();
            reader.readAsDataURL(files[0]);
            reader.onloadend = function(){
                $("#uploadform").attr("action","../api/file/upload?token="+basedata.token).submit(function(e){
                    	$(this).ajaxSubmit(function(message) {
							data=message.datum.photoimage;
							$("#uploadPreview").css("background-image","url("+data+")");
						});
                    	return false;
                  });
                $("#sub").trigger("click");
            };
        }
    });
    getCityList();
});
function publishBusinessOppo(data) {
	var $name =$("#name").val();
	var $tel = $("#tel").val();
	var $industry =$("#industry").val();
	var $area = $("#area").val();
	var $begintime =$("#begintime").val();
	var $endtime = $("#endtime").val();
	var $description =$("#description").val();
	var $title = $("#title").val();
	var updatedata="&bititle="+$title+"&bicontactname="+$name+"&bicontacttell="+$tel+"&bicontacttrade="+
	$industry+"&bicontactaddress="+$area+"&bicontactvalidity="+$begintime+$endtime+"&bicommnet="+$description
	+"&biimages="+data+"&isopen=0";	
	var Post="mid="+basedata.mid+"&groupid="+basedata.groupid+"&did="+commondata.groupbusinessoppo
	+"&token="+basedata.token+updatedata;
	$.ajax({
		url:'../../api/group/sendgroupbusinessinfo',
		type:'post',
		data:Post,
		success:function(msg){
			if (msg.code == 100) {
				alert(1);
			}
		}
	});
}
function getIndustry(){
	var Post ="mid="+basedata.mid+"&groupid="+basedata.groupid+"&token="+basedata.token+"&did="+commondata.industry+"&pagesize=5";
	$.ajax({
		url:'../../api/group/gettradelist',
		type:'post',
		data:Post,
		success:function(msg){
			
		}
	});	
}
function getCityList() {
	$.ajax({
		url:'../../source/json/city.json',
		type:'get',
		success:function(){
			
		}
	});
	
}